package com.outsourcing.bottle.adapter;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.outsourcing.bottle.R;
import com.outsourcing.bottle.domain.GroupFriendEntry;
import com.outsourcing.bottle.ui.HomeActivity;
import com.outsourcing.bottle.ui.fragment.FriendFragment;

public class GroupFriendAdapter extends BaseAdapter {

	public FriendFragment fragment;
	private HomeActivity contact;
	private List<GroupFriendEntry> groups_list;
	
	public GroupFriendAdapter(FriendFragment fragment, HomeActivity contact,
			List<GroupFriendEntry> groups_list) {
		super();
		this.fragment = fragment;
		this.contact = contact;
		this.groups_list = groups_list;
	}

	@Override
	public int getCount() {
		return groups_list.size();
	}

	@Override
	public Object getItem(int position) {
		return groups_list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			convertView = LayoutInflater.from(contact).inflate(
					R.layout.list_myfriend_group_item, null);
		}
		TextView tv = (TextView) convertView.findViewById(R.id.name);
		tv.setText(((GroupFriendEntry) getItem(position)).getGroupname());

		return convertView;
	}

}
